#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/7/31 13:15
# @Author  : Mark
# @File    : sale_exchange_rate.py
# @Software: PyCharm
from odoo import api, fields, models, _


class forpro_tax_selection(models.Model):
    _name = 'tax.selection'
    _description = '税项选择'

    order_id = fields.Many2one('sale.order', string='订单')
    tax_id = fields.Many2one(
        'account.tax',
        string='税项',
        required=True,
        domain=lambda self: [('company_id', '=', self.env.company.id)]
    )
    purchase_id = fields.Many2one('purchase.order', string='采购订单')

    def action_mass_convert(self):
        if self.order_id:

            self.order_id.order_line.update({'tax_id': self.tax_id})
        elif self.purchase_id:

            self.purchase_id.order_line.update({'taxes_id': self.tax_id})
        return {'type': 'ir.actions.act_window_close'}
